<?php
	include "DBProperties.php";
	
	if(isset($_GET['code']))
	{
		connectToSQL();
		checkLogInDetails();
		closeConnection();
	}
	
	function checkLogInDetails()
	{
		global $databaseName, $connection, $codetable;
		mysql_select_db($databaseName, $connection);
		$sqlString = "SELECT * FROM users WHERE Unique_ID = " . $_GET['code'] . " AND Last_Log >= DATE_SUB(NOW(), INTERVAl 1 MONTH)" ;
	
		$results = mysql_query($sqlString);		
		$results = mysql_query($sqlString);
		$row = mysql_num_rows($results);
		
		if($row > 0) // has logged in --- based on SQL statement
		{
			header('Location: map.php');
		}
		else
		{
			header('Location: index.php');
			?><script language="JavaScript" type="text/javascript"> alert("Invalid User ID!"); </script><?php
		}
	}
	
?>
